$('#jkd_detail_tabs').tabs({
    border: false,
    onSelect: function (title) {
        if (title == "借款单打印") {
            // 加载合同文本
            $.ajax({
                type: "POST",
                url: $.webPath() + '/jhgl/jkd/jkdDetail?jkdId=' + $("#jkd_id").val(),
                dataType: "html",
                beforeSend: function () {
                    $.messager.progress();
                },
                success: function (data) {
                    $.messager.progress("close");
                    $('#jkddetail_jkd_id').html(data);
                }
            });
        }
    }
});

$(function(){
    $("#fksh_fkshmx_table").datagrid({
        onLoadSuccess:function(){
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        }
    })
})


//  检查插件
function jkd_detail_checkIsInstall() {
    try {
        var LODOP = getLodop(document.getElementById('CGD_LODOP_OB'), document.getElementById('CGD_LODOP_EM'));
        if ((LODOP != null) && (typeof(LODOP.VERSION) != "undefined"))
            alert("本机已成功安装过Lodop控件!\n  版本号:" + LODOP.VERSION);
    } catch (err) {
        alert("Error:本机未安装或需要升级!");
    }
};

// 打印预览.
function jkd_detail_printPreview() {
    var LODOP = getLodop(document.getElementById('CGD_LODOP_OB'), document.getElementById('CGD_LODOP_EM'));
    LODOP.SET_PRINT_STYLEA(0, "NotOnlyHighPrecision", true);
    LODOP.PRINT_INIT("预览采购单");
//    var inputs = document.getElementById("page").getElementsByTagName("input");
//    for (var i = 0; i < inputs.length; i++) {
//        inputs[i].setAttribute("value", inputs[i].value);
//    }
    var strBodyStyle = "<style  type=\"text/css\">" +
        ".textcon{padding:8px;}" +
        ".input-tian{border-top:0 none;border-left:0 none;border-right:0 none;border-bottom: 1px solid black;height:22px;line-height:22px;width:100%;font-weight: bold;}" +
        " select{display:none}" +
        ".tb{width:auto;border-collapse:collapse;border-spacing:0;}" +
        ".tb th{padding:2px 2px 2px 12px;font-size:12px;font-weight:normal;text-align: right;}" +
        ".tb td{padding:2px;font-size:12px;}" +
        ".tb caption{ font-size:24px;height:60px;line-height:20px;}" +
        ".intb{width: 100%;}" +
        ".intb,.intb th,.intb td{border:1px solid black;}" +
        "</style>";
    var strFormHtmltop = strBodyStyle + "<div class='textcon'>" + document.getElementById("jkddetail_print_id").innerHTML + "</div>";
    var strFormHtmlbody = strBodyStyle +"<div class='textcon'>" + document.getElementById("jkddetail_jkd_id").innerHTML + "</div>";
    var strFormHtmlBottom = strBodyStyle +"<div class='textcon'>" + document.getElementById("jkddy_print_end").innerHTML + "</div>";


//    LODOP.SET_PRINT_PAGESIZE(0, '2640', '2790', "CreateCustomPage");
//    LODOP.ADD_PRINT_HTM(50, 80, "82%", "90%", strFormHtmltop + strFormHtmlbody + strFormHtmlBottom);
//    LODOP.ADD_PRINT_BARCODE(50, "85%", 90, 90, 'QRCode', cgd_cgdh + " " + cgd_ewmtime);
//    LODOP.SET_PRINT_PAGESIZE(0, '2640', '1230', "CreateCustomPage");
    LODOP.ADD_PRINT_TABLE(140, "1.5%", "90%", 350, strFormHtmlbody);
    LODOP.SET_PRINT_STYLEA(0,"Vorient",3);
    LODOP.ADD_PRINT_HTM(20, "1.5%", "90%", 145, strFormHtmltop);
    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
    LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
    LODOP.ADD_PRINT_HTM(495, "1.5%", "90%", 200, strFormHtmlBottom);
    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
    LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1);
//    LODOP.ADD_PRINT_BARCODE(20, "85%", 90, 90, 'QRCode', cgd_cgdh + " " + cgd_ewmtime);
//    LODOP.SET_PRINT_STYLEA(0, "QRCodeVersion", 3);
    LODOP.ADD_PRINT_TEXT(5,"80%",135,20,"总页号：第#页/共&页");
    LODOP.SET_PRINT_STYLEA(0,"ItemType",2);
    LODOP.SET_PRINT_STYLEA(0,"Horient",1);
    LODOP.PREVIEW();
}